package com.cipe.cmrs.controllers.reports;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.cipe.cmrs.model.User;
import com.cipe.cmrs.service.CipeprojectstatusService;
import com.cipe.cmrs.service.CountryService;
import com.cipe.cmrs.service.DonorService;
import com.cipe.cmrs.service.DonorawardService;
import com.cipe.cmrs.service.DonorawardstatusService;
import com.cipe.cmrs.service.RegionService;
import com.cipe.cmrs.service.SsrsReportService;
import com.cipe.cmrs.service.UserService;
import com.cipe.cmrs.ssrs.requestmodels.ActiveProjectListQuery;

/**
 * This class is used for getting the parameter entry popup page form for getting the SSRS Active Projects List. 
 * @author Shishir Lamichhane
 *
 */
@Controller
@RequestMapping("/secure/showActiveProjectQueryForm.do")
public class ActiveProjectReportController {
	@Autowired
	private RegionService regionService;
	@Autowired
	private CipeprojectstatusService cipeprojectstatusService;
	@Autowired
	private DonorawardService donorawardService;
	@Autowired
	private DonorService donorService;
	@Autowired
	private UserService userService;
	
	protected static final String COMMAND_NAME = "activeProjectListQuery";
	private static final String FORM_VIEW = "reportForms/activeReportForm";
	
	@Autowired
	private SsrsReportService ssrsReportService;
		
	
	@RequestMapping(method = RequestMethod.GET)
    protected ModelAndView getFormView(@ModelAttribute(COMMAND_NAME) ActiveProjectListQuery command, HttpServletRequest request) {
		ModelAndView model=new ModelAndView(FORM_VIEW);
		model.addObject("regionList", regionService.findAllOrderBy("displayName"));		
		model.addObject("donorawardList", donorawardService.getAllDonoraward());
		model.addObject("donorList", donorService.getAllDonors());			
	    model.addObject("programOfficerList", userService.findAll());
	    model.addObject("cipeprojectstatusList", cipeprojectstatusService.findAllOrderBy("displayName"));
		
		
		return model.addAllObjects(getReferenceData(command, request));
    }
	
	protected Map<String, Object> getReferenceData(ActiveProjectListQuery command, HttpServletRequest request) {
        return new HashMap<String, Object>();
    }

}
